package com.ruoyi.camp.api;

import com.ruoyi.camp.domain.Camp;
import com.ruoyi.camp.service.ICampService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/wechat/camp")
public class WxCampController extends BaseController
{
    @Autowired
    private ICampService campService;

    /**
     * 查询营地列表
     */
    @GetMapping("/list")
    public AjaxResult list(Camp camp)
    {
        List<Camp> list = campService.selectCampList(camp);
        return success(list);
    }
    /**
     * 获取营地详细信息
     */
    @GetMapping(value = "/{campid}")
    public AjaxResult getInfo(@PathVariable("campid") String campid)
    {
        return success(campService.selectCampByCampid(campid));
    }

    /**
     * 新增营地
     */
    @PostMapping
    public AjaxResult add(@RequestBody Camp camp)
    {
        return success(campService.insertCamp(camp));
    }

    /**
     * 修改营地
     */
    @PutMapping
    public AjaxResult edit(@RequestBody Camp camp)
    {
        return toAjax(campService.updateCamp(camp));
    }

    /**
     * 删除营地
     */
    @DeleteMapping("/{campid}")
    public AjaxResult remove(@PathVariable String campid)
    {
        return toAjax(campService.deleteCampByCampid(campid));
    }
//    @DeleteMapping("/{campids}")
//    public AjaxResult remove(@PathVariable String[] campids)
//    {
//        return toAjax(campService.deleteCampByCampids(campids));
//    }
}